<%@ page language="java"  import="java.util.*" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
	<div class="container">
	<div class="row clearfix">
		<div class="col-md-12 column">
			<h3 class="text-center">
				远程电脑控制系统
			</h3>
		</div>
	</div>
	<hr>
	<div class="row clearfix">
		<div class="col-md-4 col-lg-4 col-xs-4 column">
		</div>
			<div class="col-md-4 col-lg-4 col-xs-4 column">
				<c:forEach items="${requestScope.pcNames}" var="pc">
					<div class="row clearfix" style="padding-top:20px;'">
						<div class="col-xs-6 col-md-6 col-lg-6 column">
							<span>${pc}</span>
						</div>
						<div class="col-xs-6 col-md-6 col-lg-6 column">
							<button type="button" class="btn btn-default CtrlBtn">开机</button>
						</div>
					</div>
				</c:forEach>
			</div>
		<div class="col-md-4 col-lg-4 col-xs-4 column">
		</div>
	</div>
</div>
<script type="text/javascript">
	$(document).ready(function(){
		  $(".CtrlBtn").click(function(){
			  var pcname = $(this).parent().prev().children().text();
			  console.log("<%=basePath%>");
			  htmlobj=$.ajax({url:"<%=basePath%>servlet/PowerCtrl/setPcStatus?pcname="+pcname,async:false});
			  $("#myDiv").html(htmlobj.responseText);
		  });
		});
</script>
</body>
</html>